Welcome back.
In this lecture, we're going to take a look at creating our first script and writing down our first
lines of code to create a new script inside of our game.
What we're going to do is we're going to hop into our Explorer menu here and to create a new object
inside of our server script service, we can hit this plus button here or we can right click it and
select the insert object option.
And inside of here we can go ahead and select a script if it automatically shows up for you here.
But if it doesn't, we can also search for a script as well.
And this is the script that we would like to insert into our game.
And a script is simply just a container of Lewis code that gets executed during the runtime of our game.
Inside of our script, you may see that there's already some code inside of here, which is a print
function, printing out some text that would appear inside of our console or our output menu.
Now what we could do inside of this print function is we're going to erase what's inside of here and
we're going to pass our own custom text that we would like to print into the console.
So what we need to do is we would need to create a string data type, which we can create using either
double quotations or a single quotation.
And a string is simply a collection or a string of characters.
So we can go ahead and type within this print function here a message like Hello and hi.
This line that I've created right here is called a statement.
And a statement is simply a line of code that is telling the computer to do a specific task.
If I wanted the computer to change the color of a part to be blue, that would be a statement.
If I had a line of code that killed a player, that would also be a statement.
We can also use this print function multiple different times by first typing out the identifier for
this print function, which would be print, and then to call this print function, I would have to
use two parentheses so I can put in the first one and the second one automatically gets filled out for
me.
And now we can pass even more text inside of this print statement so I can type out another message
like Hello World.
And if you'd like to pass multiple string data types to this print function, you can separate them
by using a comma.
And I'm going to create another string here and say something like, This is the best course on Lulu
scripting.
Now, if you have a very keen eye, you should see that a new tab has appeared inside of studio.
This is the script tab, which contains some extra buttons and features for working on scripts such
as some buttons for when you're working in team.
Create and replacing some text, finding some text in a certain script and stuff like that.
We will be going more in depth about the features of the script tab later in the course, but for now,
in this tab, let's go ahead and run our script by going to this play button and hitting the dropdown
menu here and we're going to hit run.
Or you can also press F8 on your keyboard.
So now that our game has run inside of our output menu, we have the text from our script printed inside
of the console.
The console will also tell you whether or not the server or a client printed this message and it also
tells you the name of the script that printed it and at what line that this text was printed into the
console.
So as you can see in line one of our script we printed out Hello and Hi.
And at line two of our script we printed out Hello World.
And this is the best course on how to use scripting.
We can now go ahead and hit the stop button to end our testing.
And congratulations.
You have successfully created your first script and even executed your first lines of code.
Just know that it's going to get a lot crazier from this point forward.
For now, what I'd like for you to do is to continue messing with this print function, multiple calls
if you'd like, and continue to print any types of text that you'd like into the console.
In the next lecture, I'm going to explain to you the concept of variables and how you can use them
in your scripts.
See you there.